import {
  Controller,
  Post,
  Body,
  UseInterceptors,
  UploadedFile
} from '@nestjs/common'
import { MulterService } from './multer.service'
// import { CreateMulterDto } from './dto/create-multer.dto'
// import { UpdateMulterDto } from './dto/update-multer.dto'
import { FileInterceptor } from '@nestjs/platform-express'
import { multerStorage } from '../utils/multer.storage'

@Controller('multer')
export class MulterController {
  constructor(private readonly multerService: MulterService) {}

  @Post()
  @UseInterceptors(
    FileInterceptor('file', {
      dest: 'uploads',
      storage: multerStorage
    })
  )
  uploadFile(@UploadedFile() file: Express.Multer.File, @Body() body) {
    console.log(file)
    console.log(body)
    return file.filename
  }
}
